package com.system.healthproject.controller;

import com.system.healthproject.common.ApiResult;
import com.system.healthproject.model.admin.paramsbean.AbnormalEEGParams;
import com.system.healthproject.model.admin.paramsbean.DiseaseOnsetParams;
import com.system.healthproject.model.admin.paramsbean.DrugParams;
import com.system.healthproject.model.admin.paramsbean.SymptomParams;
import com.system.healthproject.pojo.*;
import com.system.healthproject.service.CommonParamsService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;


@RestController
@RequestMapping(value = "/params",produces = "application/json;charset=utf-8")
@Api(value = "公共参数管理",tags = "后端-公共参数管理API")
@Validated
public class CommonParamsController {

    @Autowired
    CommonParamsService commonParamsService;

    @ApiOperation(value = "添加诊断症状(后端已调)")
    @PostMapping(value = "/addSymptom")
    public ApiResult addSymptom(
            @Validated
            @RequestBody @ApiParam(value = "诊断症状",required = true)
                    SymptomParams symptom){
        boolean b = commonParamsService.addSymptom(symptom);
        return ApiResult.withBoolean(b);
    }
    @ApiOperation(value = "删除诊断症状(后端已调)")
    @PostMapping(value = "/deleteSymptom")
    public ApiResult deleteSymptom(@NotNull(message = "id不能为空") Integer id){
        boolean b = commonParamsService.deleteSymptom(id);
        return ApiResult.withBoolean(b);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "symptomType",value = "症状类型",required = true),
    })
    @ApiOperation(value = "添加诊断症状类型(后端已调)")
    @PostMapping(value = "/addSymptomType")
    public ApiResult addSymptomType(@NotBlank(message = "症状类型不能为空") String symptomType){
        boolean b = commonParamsService.addSymptomType(symptomType);
        return ApiResult.withBoolean(b);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "symptomType",value = "症状类型id不能为空",required = true),
    })
    @ApiOperation(value = "删除诊断症状类型(后端已调)")
    @PostMapping(value = "/deletSymptomType")
    public ApiResult deleteSymptomType(
            @NotBlank(message = "症状类型id不能为空")
                    Integer symptomTypeId){
        boolean b = commonParamsService.deleteSymptomType(symptomTypeId);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "获取诊断症状类型列表(后端已调)")
    @GetMapping(value = "/SymptomTypeList")
    public ApiResult<List<SymptomType>> symptomTypeList(){
        List<SymptomType> symptomTypes = commonParamsService.symptomTypeList();
        return ApiResult.successWithData("成功",symptomTypes);
    }


    @ApiImplicitParams({
            @ApiImplicitParam(name = "typeId",value = "类型id",required = true),
    })
    @ApiOperation(value = "根据类型获取诊断症状列表(后端已调)")
    @GetMapping(value = "/SymptomListByType")
    public ApiResult<List<Symptom>> SymptomListByType(
            @NotNull(message = "id不能为空") Integer typeId){
        List<Symptom> symptoms = commonParamsService.symptomListByType(typeId);
        return ApiResult.successWithData("成功",symptoms);
    }

    @ApiOperation(value = "添加综合征(后端已调)")
    @PostMapping(value = "/addDiseaseOnset")
    public ApiResult addDiseaseOnset(
            @Validated
            @RequestBody
            @ApiParam(value = "综合征",required = true) DiseaseOnsetParams symptom){
        boolean b = commonParamsService.addDiseaseOnset(symptom);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "删除综合征(后端已调)")
    @PostMapping(value = "/deleteDiseaseOnset")
    public ApiResult deleteDiseaseOnset(
            @NotNull(message = "id不能为空")
            Integer id){
        boolean b = commonParamsService.deleteDiseaseOnset(id);
        return ApiResult.withBoolean(b);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "diseaseonsettypeName",value = "综合征类型名称",required = true),
    })
    @ApiOperation(value = "添加综合征类型(后端已调)")
    @PostMapping(value = "/addDiseaseOnsetType")
    public ApiResult addDiseaseOnsetType(
            @NotBlank(message = "综合征类型不能为空") String diseaseonsettypeName){
        boolean b = commonParamsService.addDiseaseOnsetType(diseaseonsettypeName);
        return ApiResult.withBoolean(b);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "diseaseonsettypeId",value = "综合征类型id",required = true),
    })
    @ApiOperation(value = "删除综合征类型(后端已调)")
    @PostMapping(value = "/deleteDiseaseOnsetType")
    public ApiResult deleteDiseaseOnsetType(
            @NotNull(message = "综合征类型id不能为空") Integer diseaseonsettypeId){
        boolean b = commonParamsService.deleteDiseaseOnsetType(diseaseonsettypeId);
        return ApiResult.withBoolean(b);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "typeId",value = "类型id",required = true),
    })
    @ApiOperation(value = "获取综合症列表(后端已调)")
    @GetMapping(value = "/diseaseOnsetListByType")
    public ApiResult<List<DiseaseOnset>> diseaseOnsetListByType(
            @NotNull Integer typeId){
        List<DiseaseOnset> diseaseOnsets = commonParamsService.diseaseOnsetListByType(typeId);
        return ApiResult.successWithData("成功",diseaseOnsets);
    }

    @ApiOperation(value = "获取综合症类型列表(后端已调)")
    @GetMapping(value = "/diseaseOnsetTypeList")
    public ApiResult<List<DiseaseOnsetType>> diseaseOnsetTypeList(){
        List<DiseaseOnsetType> diseaseOnsetTypes = commonParamsService.diseaseOnsetTypeList();
        return ApiResult.successWithData("成功",diseaseOnsetTypes);
    }


    @ApiOperation(value = "添加脑电图异常(后端已调)")
    @PostMapping(value = "/addEEG")
    public ApiResult addEEG(
            @Validated
            @RequestBody
            @ApiParam(value = "脑电图异常",required = true)
                    AbnormalEEGParams abnormalEEGParams){
        boolean b = commonParamsService.addEEG(abnormalEEGParams);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "删除脑电图异常(后端已调)")
    @PostMapping(value = "/deleteEEg")
    public ApiResult deleteEEg(
            @NotNull Integer eegId){
        boolean b = commonParamsService.deleteEEg(eegId);
        return ApiResult.withBoolean(b);
    }



    @ApiImplicitParams({
            @ApiImplicitParam(name = "abnormaleegtypeName",value = "脑电图异常类型名称",required = true),
    })
    @ApiOperation(value = "添加脑电图异常类型(后端已调)")
    @PostMapping(value = "/addEEGType")
    public ApiResult addEEGType(
            @NotBlank String abnormaleegtypeName){
        boolean b = commonParamsService.addEEGType(abnormaleegtypeName);
        return ApiResult.withBoolean(b);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "abnormaleegtypeId",value = "脑电图异常类型名称",required = true),
    })
    @ApiOperation(value = "删除脑电图异常类型(后端已调)")
    @PostMapping(value = "/deleteEEGType")
    public ApiResult deleteEEGType(
            @NotNull Integer abnormaleegtypeId){
        boolean b = commonParamsService.deleteEEGType(abnormaleegtypeId);
        return ApiResult.withBoolean(b);
    }


    @ApiImplicitParams({
            @ApiImplicitParam(name = "typeId",value = "类型id",required = true),
    })
    @ApiOperation(value = "获取脑电图异常列表(后端已调)")
    @GetMapping(value = "/eeGListByType")
    public ApiResult<List<AbnormalEEG>> eeGListByType(
            @NotNull Integer typeId){
        List<AbnormalEEG> abnormalEEGS = commonParamsService.eeGListByType(typeId);
        return ApiResult.successWithData("成功",abnormalEEGS);
    }


    @ApiOperation(value = "获取脑电图异常类型列表(后端已调)")
    @GetMapping(value = "/eeGTypeList")
    public ApiResult<List<AbnormalEEGType> > eeGTypeList(){
        List<AbnormalEEGType> abnormalEEGTypes = commonParamsService.eeGTypeList();
        return ApiResult.successWithData("成功",abnormalEEGTypes);
    }



    @ApiOperation(value = "添加药品(后端已调)")
    @PostMapping(value = "/addDrug")
    public ApiResult addDrug(
            @Validated
            @RequestBody
            @ApiParam(value = "药品",required = true) DrugParams drugParams){
        boolean b = commonParamsService.addDrug(drugParams);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "删除药品(后端已调)")
    @PostMapping(value = "/deleteDrug")
    public ApiResult deleteDrug(
            @NotNull
           Integer drugId){
        boolean b = commonParamsService.deleteDrug(drugId);
        return ApiResult.withBoolean(b);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "drugtypeName",value = "药品类型名称",required = true),
    })
    @ApiOperation(value = "添加药品类型(后端已调)")
    @PostMapping(value = "/addDrugType")
    public ApiResult addDrugType(
            @NotBlank String drugtypeName){
        boolean b = commonParamsService.addDrugType(drugtypeName);
        return ApiResult.withBoolean(b);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "drugtypeId",value = "药品类型id",required = true),
    })
    @ApiOperation(value = "删除药品类型(后端已调)")
    @PostMapping(value = "/deleteDrugType")
    public ApiResult deleteDrugType(
            @NotNull Integer drugtypeId){
        boolean b = commonParamsService.deleteDrugType(drugtypeId);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "获取药品类型列表(后端已调)")
    @GetMapping(value = "/DrugTypeList")
    public ApiResult<List<DrugType>> DrugTypeList(){
        List<DrugType> drugTypes = commonParamsService.DrugTypeList();
        return ApiResult.successWithData("成功",drugTypes);
    }


    @ApiImplicitParams({
            @ApiImplicitParam(name = "typeId",value = "类型id",required = true),
    })
    @ApiOperation(value = "获取药品列表(后端已调)")
    @GetMapping(value = "/drugListByTypeId")
    public ApiResult<List<Drug>> drugListByTypeId(
            @NotNull Integer typeId){
        List<Drug> drugs = commonParamsService.drugListByTypeId(typeId);
        return ApiResult.successWithData("成功",drugs);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "ctName",value = "核磁异常名称",required = true),
    })
    @ApiOperation(value = "添加核磁异常(后台已调)")
    @PostMapping(value = "/addCt")
    public ApiResult addCt(@NotBlank String ctName){
        boolean b = commonParamsService.addCt(ctName);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "删除CT(后端已调)")
    @PostMapping(value = "/deleteCt")
    public ApiResult deleteCt(
            @NotNull
            Integer ctId){
        boolean b = commonParamsService.deleteCt(ctId);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "核磁异常列表(后台已调)")
    @GetMapping(value = "/ctList")
    public ApiResult<List<Ct>> ctList(){
        List<Ct> ctList = commonParamsService.ctList();
        return ApiResult.successWithData("成功",ctList);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "operationName",value = "手术名称",required = true),
    })
    @ApiOperation(value = "添加手术(后台已调)")
    @PostMapping(value = "/addOperation")
    public ApiResult addOperation(@NotBlank String operationName){
        boolean b = commonParamsService.addOperation(operationName);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "删除手术(后端已调)")
    @PostMapping(value = "/deleteOperation")
    public ApiResult deleteOperation(
            @NotNull
            Integer operationId){
        boolean b = commonParamsService.deleteOperation(operationId);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "手术列表(后台已调)")
    @GetMapping(value = "/operationList")
    public ApiResult<List<Operation>> operationList(){
        List<Operation> operations = commonParamsService.operationList();
        return ApiResult.successWithData("成功",operations);
    }


    @ApiImplicitParams({
            @ApiImplicitParam(name = "chronicName",value = "慢病史名称",required = true),
    })
    @ApiOperation(value = "添加慢病史(后台已调)")
    @PostMapping(value = "/addChronic")
    public ApiResult addChronic(
            @NotBlank String chronicName){
        boolean b = commonParamsService.addChronic(chronicName);
        return ApiResult.withBoolean(b);
    }


    @ApiOperation(value = "删除慢病史(后台已调)")
    @PostMapping(value = "/deleteChronic")
    public ApiResult deleteChronic(
            @NotNull Integer chronicId){
        boolean b = commonParamsService.deleteChronic(chronicId);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "慢病史列表(后台已调)")
    @GetMapping(value = "/chronicList")
    public ApiResult<List<Chronic>> chronicList(){
        List<Chronic> chronics = commonParamsService.chronicList();
        return ApiResult.successWithData("成功",chronics);
    }


    @ApiImplicitParams({
            @ApiImplicitParam(name = "chronicName",value = "家族病史名称",required = true),
    })
    @ApiOperation(value = "添加家族病史名称(后台已调)")
    @PostMapping(value = "/addInheritance")
    public ApiResult addInheritance(
            @NotBlank String chronicName){
        boolean b = commonParamsService.addInheritance(chronicName);
        return ApiResult.withBoolean(b);
    }


    @ApiOperation(value = "删除家族病史名称(后台已调)")
    @PostMapping(value = "/deleteInheritance")
    public ApiResult deleteInheritance(
            @NotNull Integer inheritanceId){
        boolean b = commonParamsService.deleteInheritance(inheritanceId);
        return ApiResult.withBoolean(b);
    }

    @ApiOperation(value = "家族病史列表(后台已调)")
    @GetMapping(value = "/inheritanceList")
    public ApiResult<List<Inheritance>> inheritanceList(){
        List<Inheritance> inheritances = commonParamsService.inheritanceList();
        return ApiResult.successWithData("成功",inheritances);
    }



}
